package com.jluzh10.learning.dao;

import com.jluzh10.learning.domain.Answer;
import com.jluzh10.learning.domain.Question;
import com.jluzh10.learning.domain.QuestionExample;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface QuestionMapper {
    long countByExample(QuestionExample example);

    int deleteByExample(QuestionExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Question record);

    int insertSelective(Question record);

    List<Question> selectByExample(QuestionExample example);

    Question selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Question record, @Param("example") QuestionExample example);

    int updateByExample(@Param("record") Question record, @Param("example") QuestionExample example);

    int updateByPrimaryKeySelective(Question record);

    int updateByPrimaryKey(Question record);

    /*自定义方法*/

    /**
     * 根据时间排序查出该用户最新添加的问题和用户信息
     * @param
     * @return
     */
    Question searchQNUser(Integer id);

   //==========================//
    /**
     * 根据查询对象查询所有问题并同时查询每个问题对应的最新回答，两个方法同时执行
     * @return
     */
    List<Question> searchAllQuestion(Question question);
    /**
     * 根据问题id查询所有问题的最新回答
     * @param id 问题id
     * @return
     */
    Answer searchLatestAnswer(Integer id);

    //=========================//
}